package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.server.service.SmallVideosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/smallVideos")
public class SmallVideosController {

    @Autowired
    private SmallVideosService smallVideosService;
    /**
     * 上传视频
     * */
    @PostMapping
    public ResponseEntity smallVideos(MultipartFile videoThumbnail,MultipartFile videoFile) throws IOException {
            //封面 视频文件
        smallVideosService.smallVideos(videoThumbnail,videoFile);

        return ResponseEntity.ok(null);
    }
    /**
     * 视频列表
     * */
    @GetMapping
    public ResponseEntity findVideos(@RequestParam(defaultValue = "1")Integer page,
                                     @RequestParam(defaultValue = "10")Integer pagesize){
        PageResult vo = smallVideosService.findVideos(page,pagesize);
        return ResponseEntity.ok(vo);
    }
}
